use core::mem;

pub const MAGIC: &[u8] = b"MOYU";

#[repr(u8)]
#[derive(Debug, Copy, Clone)]
pub enum Operator {
    Request = 0,
    Reply,
    SendMessage,
    TransmitMessage,
    Query,
    Tell,
    Unknown,
}

impl From<u8> for Operator {
    fn from(op: u8) -> Self {
        if op >= unsafe { mem::transmute(Operator::Unknown) } {
            Operator::Unknown
        } else {
            unsafe { mem::transmute(op) }
        }
    }
}

impl Into<u8> for Operator {
    fn into(self) -> u8 {
        unsafe { mem::transmute(self) }
    }
}
